package com.jiangxjsy.core.common;

import com.jiangxjsy.core.constant.CrmModuleConstant;
import lombok.Getter;

/**
 * wukong-crm-master
 * 蒋胜宇
 * 2025/6/18 15:04
 */

@Getter
public enum CrmModule {
    LEADS(CrmModuleConstant.LEADS.getKey(), CrmModuleConstant.LEADS.getValue()),
    CUSTOMER(CrmModuleConstant.CUSTOMER.getKey(), CrmModuleConstant.CUSTOMER.getValue()),
    CONTACTS(CrmModuleConstant.CONTACTS.getKey(), CrmModuleConstant.CONTACTS.getValue()),
    PRODUCT(CrmModuleConstant.PRODUCT.getKey(), CrmModuleConstant.PRODUCT.getValue()),
    BUSINESS(CrmModuleConstant.BUSINESS.getKey(), CrmModuleConstant.BUSINESS.getValue()),
    CONTRACT(CrmModuleConstant.CONTRACT.getKey(), CrmModuleConstant.CONTRACT.getValue()),
    RECEIVABLES(CrmModuleConstant.RECEIVABLES.getKey(), CrmModuleConstant.RECEIVABLES.getValue()),
    RECEIVABLES_PLAN(CrmModuleConstant.RECEIVABLES_PLAN.getKey(), CrmModuleConstant.RECEIVABLES_PLAN.getValue()),
    CUSTOMER_POOL(CrmModuleConstant.CUSTOMER_POOL.getKey(), CrmModuleConstant.CUSTOMER_POOL.getValue()),
    MARKETING(CrmModuleConstant.MARKETING.getKey(), CrmModuleConstant.MARKETING.getValue()),
    RETURN_VISIT(CrmModuleConstant.RETURN_VISIT.getKey(), CrmModuleConstant.RETURN_VISIT.getValue()),
    INVOICE(CrmModuleConstant.INVOICE.getKey(), CrmModuleConstant.INVOICE.getValue()),
    NULL(CrmModuleConstant.NULL.getKey(),CrmModuleConstant.NULL.getValue());

    private final Integer type;
    private final String remarks;

    CrmModule(Integer type, String remarks) {
        this.type = type;
        this.remarks = remarks;
    }

    public static CrmModule parse(Integer type) {
        for (CrmModule crmModule : CrmModule.values()) {
            if (crmModule.getType().equals(type)) {
                return crmModule;
            }
        }
        return NULL;
    }

    public static CrmModule parse(String name) {
        for (CrmModule crmModule : CrmModule.values()) {
            if (crmModule.name().equals(name)) {
                return crmModule;
            }
        }
        return NULL;
    }

    public String getTableName() {
        return name().toLowerCase();
    }
}
